package touchtouch;

import javax.swing.JFrame;
import javax.swing.JPanel;

import wiiusej.WiiUseApiManager;
import wiiusej.Wiimote;
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.utils.WiimoteListener;
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;

public class WiiTestPanel extends JPanel implements WiimoteListener{


	public void onButtonsEvent(WiimoteButtonsEvent arg0) {}
	public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent arg0) {}
	public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {}
	public void onDisconnectionEvent(DisconnectionEvent arg0) {}
	public void onExpansionEvent(ExpansionEvent arg0) {}
	public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {}
	public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {}
	public void onIrEvent(IREvent arg0) {}
	public void onMotionSensingEvent(MotionSensingEvent arg0) {}
	public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {}
	public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {}
	public void onStatusEvent(StatusEvent arg0) {}


	public static void main(String[] argv){
		//WiiUseApiManager.shutdown();
		// detection des wiimotes
		Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, false);
        Wiimote wiimote = wiimotes[0];
        //activation de la détection l'infrarouge
        wiimote.activateIRTRacking();
        //sensibilité de l'IR
        wiimote.setIrSensitivity(5);
        //wiimote.activateSmoothing();
        wiimote.deactivateMotionSensing();
        wiimote.deactivateRumble();


        //wiimote.activateContinuous();
        //création du panel
        JFrame frame = new JFrame("WiiTest");
        WiiTestPanel panel = new WiiTestPanel();
        frame.add(panel);
        frame.setSize(800, 600);
        frame.setVisible(true);
        // détection des coins
        CornersListener cornersListener = new CornersListener(panel, wiimote);
        wiimote.addWiiMoteEventListeners(cornersListener);
        //récupération des coordonnées des 4 coins pour le callibrage


        wiimote.addWiiMoteEventListeners(panel);

	}

}
